<?php
/**
 * 电子书控制器
 */
class Index extends BaseAction
{
	/**
	 * 初始化
	 */
	public function _init()
	{

	}

	/**
	 * 默认动作
	 */
	protected function _default()
	{
		#获取到登录信息
		$loginId = $this->session()->getSession('front_uid');
		$loginName = $this->session()->getSession('front_uname');
		
		$this->assign('loginId',$loginId);
		$this->assign('loginName',$loginName);
		$this->tpl_full_path('/front/cooperate/index');
	}
	/**
	 * 项目信息备案
	 */
	protected function _step1()
	{

	 if($_SERVER["REQUEST_METHOD"] === "POST"   && $_POST['step1']==1){
//		 print_r($_POST);exit;
		 $data['projectName'] = $this->getParam('projectName','t');#
		 $data['projectArea'] = $this->getParam('area','t');#
		 $data['constructionName'] = $this->getParam('constructionName','t');#
		 $data['projectType'] = $this->getParam('nature');#
		 $data['countryCode']=$this->getParam('hidden_countrycode','i');
		 $data['address'] = $this->getParam('address','t');#
		 $data['firstTime'] = time();#

		 $data['sortid'] = '999';#
		 $data['company'] = '999';#
		 $data['content'] = '999';#

		 $id=DB::insert("pc_project",$data,true);

		 if($id ){

			 $url='http://www.gzcanr.com/cooperate/index-cmd-step2-id-'.$id.'.html';
			 $this->goTo301($url);
		 }else{
			 $this->alertBack("保存失败,请重试！");
		 }



	 }

		$this->tpl_full_path('/front/cooperate/step1');
	}


	protected function _step2()
	{

		$id = $this->getParam('id','i');
		if($_SERVER["REQUEST_METHOD"] === "POST"   && $_POST['step2']==2) {
//			print_r($_POST);exit;
//			if ($id > 0) {
//					$url='http://www.gzcanr.com/cooperate/index-cmd-step3-id-'.$id.'.html';
//					$this->goTo301($url);
//				}else{
//					$this->alertBack("保存失败,请重试！");
//				}
			}

		$this->tpl_full_path('/front/cooperate/step2');
	}


	protected function _step3()
	{

		$id = $this->getParam('id','i');
		if($_SERVER["REQUEST_METHOD"] === "POST"   && $_POST['step3']==3) {
			if ($id > 0) {
				$data['companyName'] = $this->getParam('company', 't');#
				$data['linkman'] = $this->getParam('linkman', 't');#
				$data['tel'] = $this->getParam('tel', 't');#
				$data['mobile'] = $this->getParam('mobile', 't');#
				$data['email'] = $this->getParam('email', 't');#
				$data['leaveWord'] = $this->getParam('content', 't');#
				$data['firstTime'] = time();#


				$sql = "update pc_project set companyName = '" . $data['companyName'] . "' ,  linkman='" . $data['linkman'] . "', tel='" . $data['tel'] . " ' , mobile='" . $data['mobile'] . " ' ,
			email='" . $data['email'] . "'  ,   leaveWord='" . $data['leaveWord'] . " ' ,   firstTime='" . $data['firstTime'] . " '        where id = " . $id;


				if(DB::execute($sql)){



					$message="提交成功,我司人员将在1个工作日内与您联系~！";
					$url='http://www.gzcanr.com/cooperate/index.html';
					$this->alertGoto($message,$url);


				}else{
					$this->alertBack("保存失败,请重试！");
				}


			}

		}

		$this->tpl_full_path('/front/cooperate/step3');
	}







/**
 * 获取到产品分类下的内容
 */
	protected function _show(){
		$isShowWhichType= $this->getParam('isShowWhichType');

		$list= $this->getParam('list');

		$arrList=explode(",",$list);


		$strTH = "";
		if($isShowWhichType=='1'){
			$strTH.='<div><i>*</i><span>材料类型：</span></div>';
			$strTH.='<div class="check-list" id="materialList">';
			foreach($arrList as $k=>$v){
				$k1=$k+1;
				$strTH.='<label>';
				$strTH.='<input   type="radio" name="materialType" class="materialList"  value="'.$k1.'"  onclick="showClickMaterial(this)"/>';
				$strTH.='<span>'.$v.'</span>';
				$strTH.='</label>';
			}
			$strTH.='</div>';
		}elseif($isShowWhichType=='2'){
			$strTH.='<div><i>*</i><span>选择灯具类型：</span></div>';
			$strTH.='            <div class="check-list">
                <label>
                    <input type="radio" name="luminaireType"   class="luminaireType" value="1" />
                    <span>LED平板灯</span>
                </label>
                <label>
                    <input type="radio" name="luminaireType" class="luminaireType"  value="2" />
                    <span>光管式LED灯</span>
                </label>
                <label>
                    <input type="radio" name="luminaireType" class="luminaireType"  value="3" />
                    <span>反光罩式荧光灯</span>
                </label>

            </div>';

		}elseif($isShowWhichType=='3'){
			$strTH.=' <div><i>*</i><span>选择风口类型：</span></div>';
			$strTH.='  <div class="check-list">
                <label>
                    <input type="radio" name="tuyereType" class="tuyereType" value="1" />
                    <span>流线型侧吹风口</span>
                </label>
                <label>
                    <input type="radio" name="tuyereType" class="tuyereType" value="2" />
                    <span>零度风口</span>
                </label>
                <label>
                    <input type="radio" name="tuyereType" class="tuyereType" value="3" />
                    <span>开孔式风口</span>
                </label>

            </div>';
		}


		$isShowProductType= $this->getParam('isShowProductType');
		$sortVal= $this->getParam('sortVal');
		$materialType= $this->getParam('materialType');
//
//		if($isShowProductType=='1'&&$sortVal=='1'){//天花
//			if($materialType==1){//天花下的铝合金
//				$strTH.='<li id="productType"  >';
//				$strTH.='<div><i>*</i><span>产品类型：</span></div>';
//				$strTH.=' <select  class="web-input productTypeSelect" name="productType" id="productTypeSelect"  onchange="showBelow(this)">';
//				$strTH.=' <option value="0">请选择</option>';
//				$strTH.=' <option value="1">标准版</option>';
//				$strTH.=' <option value="2">铝单板</option>';
//				$strTH.=' <option value="3">蜂窝板</option>';
//				$strTH.=' <option value="4">瓦楞板</option>';
//				$strTH.=' <option value="5">U形方通</option>';
//				$strTH.=' <option value="6">条扣板</option>';
//				$strTH.=' </select>';
//				$strTH.='</li>';
//			}
//
//			if($materialType==2){//天花下的不锈钢
//				$strTH.='<li id="productType"  >';
//				$strTH.='<div><i>*</i><span>产品类型：</span></div>';
//				$strTH.=' <select  class="web-input productTypeSelect" name="productType" id="productTypeSelect"  onchange="showBelow(this)">';
//				$strTH.=' <option value="0">请选择</option>';
//				$strTH.=' <option value="1">标准版</option>';
//				$strTH.=' <option value="2">异形板</option>';
//				$strTH.=' <option value="3">蜂窝板</option>';
//				$strTH.=' <option value="4">瓦楞板</option>';
//				$strTH.=' </select>';
//				$strTH.='</li>';
//			}
//
//			if($materialType==3){//天花下的镀锌钢板
//				$strTH.='<li id="productType"  >';
//				$strTH.='<div><i>*</i><span>产品类型：</span></div>';
//				$strTH.=' <select  class="web-input productTypeSelect" name="productType" id="productTypeSelect"  onchange="showBelow(this)">';
//				$strTH.=' <option value="0">请选择</option>';
//				$strTH.=' <option value="1">厚板</option>';
//				$strTH.=' <option value="3">蜂窝板</option>';
//				$strTH.=' </select>';
//				$strTH.='</li>';
//			}
//
//
//
//		}
//		elseif($isShowProductType=='1'&&$sortVal=='2'){//墙板
//			$strTH.='<li id="productType"  >';
//			$strTH.='<div><i>*</i><span>产品类型：</span></div>';
//			$strTH.=' <select  class="web-input" name="productType" id="productTypeSelect" onclick="showBelow($(this))">';
//			$strTH.=' <option value="0">请选择</option>';
//
//			$strTH.=' <option value="3">蜂窝板</option>';
//			$strTH.=' <option value="4">钢板复合</option>';
//		 ;
//			$strTH.=' </select>';
//			$strTH.='</li>';
//
//		}
//		else
			if($isShowProductType=='1'&&$sortVal=='3'){//灯具
			$strTH.='<li id="productType"  >';
			$strTH.='<div><i>*</i><span>材料类型：</span></div>';
			$strTH.=' <select  class="web-input productTypeSelect" name="productType" id="productTypeSelect"  >';
			$strTH.=' <option value="0">请选择</option>';

			$strTH.=' <option value="3">铝合金框</option>';
			$strTH.=' <option value="4">镀锌钢板</option>';
			;
			$strTH.=' </select>';
			$strTH.='</li>';

		}


		$isShowSize= $this->getParam('isShowSize');
		if($isShowSize=='1'){
			$strTH.='   <li class="raw" id="size"  >';
			$strTH.='  <div><i>*</i><span>尺寸：</span></div>';
			$strTH.='            <div class="check-list">
                <label>
                    <input type="radio" name="size" class="size" value="1" checked="checked" />
                    <span>200*1200</span>
                </label>
                <label>
                    <input type="radio" name="size"  class="size" value="2" />
                    <span>300*1200</span>
                </label>
                <label>
                    <input type="radio" name="size"  class="size" value="3" />
                    <span>400*1200</span>
                </label>

            </div>';
			$strTH.='  </li>';
		}


		$isShowNum= $this->getParam('isShowNum');
		if($isShowNum=='1'){//天花数量
			$strTH.=' <li id="num"  >';
			$strTH.=' <div><i>*</i><span>大约数量：</span></div>';
			$strTH.='  <input type="text" class="web-input count-num" name="num"      />㎡';
			$strTH.='  </li>';
		}elseif($isShowNum=='2'){//墙板数量
			$strTH.=' <li id="num"  >';
			$strTH.=' <div><i>*</i><span>大约数量：</span></div>';
			$strTH.='  <input type="text" class="web-input count-num" name="num"     />㎡';
			$strTH.='  </li>';
		}elseif($isShowNum=='3'){//灯具数量
			$strTH.=' <li id="num"  >';
			$strTH.=' <div><i>*</i><span>数量：</span></div>';
			$strTH.='  <input type="text" class="web-input count-num" name="num"   />个';
			$strTH.='  </li>';
		}elseif($isShowNum=='4'){//风口数量
			$strTH.=' <li id="num"  >';
			$strTH.=' <div><i>*</i><span>数量：</span></div>';
			$strTH.='  <input type="text" class="web-input count-num" name="num"    />个';
			$strTH.='  </li>';
		}elseif($isShowNum=='5'){//踢脚线数量
			$strTH.=' <li id="num"  >';
			$strTH.=' <div><i>*</i><span>数量：</span></div>';
			$strTH.='  <input type="text" class="web-input count-num" name="num"   />m';
			$strTH.='  </li>';
		}elseif($isShowNum=='6'){//窗帘数量
			$strTH.=' <li id="num"  >';
			$strTH.=' <div><i>*</i><span>数量：</span></div>';
			$strTH.='  <input type="text" class="web-input count-num" name="num"    />㎡';
			$strTH.='  </li>';
		}


		echo $strTH;
		exit();
	}


	/**
	 *   点击材料类型
	 */
	protected function _showClickMaterial(){
		$strTH = "";
		$sortVal= $this->getParam('sortVal');
		$materialListVal= $this->getParam('materialListVal');

		if($sortVal==1){
			if($materialListVal=='1'){
				$strTH.='<li id="productType"  >';
				$strTH.='<div><i>*</i><span>产品类型：</span></div>';
				$strTH.=' <select  class="web-input productTypeSelect" name="productType" id="productTypeSelect" >';
				$strTH.=' <option value="0">请选择</option>';
				$strTH.=' <option value="1">标准版</option>';
				$strTH.=' <option value="2">铝单板</option>';
				$strTH.=' <option value="3">蜂窝板</option>';
				$strTH.=' <option value="4">瓦楞板</option>';
				$strTH.=' <option value="5">U形方通</option>';
				$strTH.=' <option value="6">条扣板</option>';
				$strTH.=' </select>';
				$strTH.='</li>';
			}

			if($materialListVal=='2'){
				$strTH.='<li id="productType"  >';
				$strTH.='<div><i>*</i><span>产品类型：</span></div>';
				$strTH.=' <select  class="web-input productTypeSelect" name="productType" id="productTypeSelect" >';
				$strTH.=' <option value="0">请选择</option>';
				$strTH.=' <option value="2">厚板</option>';
				$strTH.=' <option value="4">蜂窝板</option>';
				$strTH.=' </select>';
				$strTH.='</li>';
			}


			if($materialListVal=='3'){
				$strTH.='<li id="productType"  >';
				$strTH.='<div><i>*</i><span>产品类型：</span></div>';
				$strTH.=' <select  class="web-input productTypeSelect" name="productType" id="productTypeSelect" >';
				$strTH.=' <option value="0">请选择</option>';
				$strTH.=' <option value="1">标准版</option>';
				$strTH.=' <option value="2">异形板</option>';
				$strTH.=' <option value="3">蜂窝板</option>';
				$strTH.=' <option value="4">瓦楞板</option>';
				$strTH.=' </select>';
				$strTH.='</li>';
			}

			$strTH.=' <li id="num"  >';
			$strTH.=' <div><i>*</i><span>大约数量：</span></div>';
			$strTH.='  <input type="text" class="web-input count-num" name="num"      />㎡';
			$strTH.='  </li>';

		}



		if($sortVal==2){
			if($materialListVal=='1'){
				$strTH.='<li id="productType"  >';
				$strTH.='<div><i>*</i><span>产品类型：</span></div>';
				$strTH.=' <select  class="web-input productTypeSelect" name="productType" id="productTypeSelect" >';
				$strTH.=' <option value="0">请选择</option>';
				$strTH.=' <option value="2">铝单板</option>';
				$strTH.=' <option value="3">蜂窝板</option>';
				$strTH.=' <option value="4">铝板复合</option>';
				$strTH.=' </select>';
				$strTH.='</li>';
			}elseif($materialListVal=='2'){
				$strTH.='<li id="productType"  >';
				$strTH.='<div><i>*</i><span>产品类型：</span></div>';
				$strTH.=' <select  class="web-input productTypeSelect" name="productType" id="productTypeSelect" onchange="showBelow(this)">';
				$strTH.=' <option value="0">请选择</option>';
				$strTH.=' <option value="2">厚板</option>';
				$strTH.=' <option value="4">蜂窝板</option>';
				$strTH.=' </select>';
				$strTH.='</li>';
			}elseif($materialListVal=='3'){
				$strTH.='<li id="productType"  >';
				$strTH.='<div><i>*</i><span>产品类型：</span></div>';
				$strTH.=' <select  class="web-input productTypeSelect" name="productType" id="productTypeSelect" onchange="showBelow(this)">';
				$strTH.=' <option value="0">请选择</option>';
				$strTH.=' <option value="2">蜂窝板</option>';
				$strTH.=' <option value="4">钢板复合</option>';
				$strTH.=' </select>';
				$strTH.='</li>';
			}

			$strTH.=' <li id="num"  >';
			$strTH.=' <div><i>*</i><span>大约数量：</span></div>';
			$strTH.='  <input type="text" class="web-input count-num" name="num"      />㎡';
			$strTH.='  </li>';
		}







		echo $strTH;
		exit();


	}



	/**
	 * step2保存
	 */
	protected function _save(){

		$id = $this->getParam('id','t');

		if( !empty($id) ){

                $productCategory = $this->getParam('productCategory');
				$resId = $this->getParam('resId');
				
                #数据组合
//				if($this->getParam('materialType', 'i')){
//					$data['secondType'] = $this->getParam('materialType', 'i');#材料类型
//				}elseif($this->getParam('luminaireType', 'i')){
//					$data['secondType'] = $this->getParam('luminaireType', 'i');#灯具类型
//				}elseif($this->getParam('tuyereType', 'i')){
//					$data['secondType'] = $this->getParam('tuyereType', 'i');#风口类型
//				}
//
//                $data['productCategory'] = $productCategory;
//				$data['productType'] = $this->getParam('productType');#
//				$data['num'] = $this->getParam('num', 'i');#
//				$data['size'] = $this->getParam('size', 'i');#


				$data['projectId'] = $id;#
				$data['productType'] = $this->getParam('productCategory');#
				$data['productNum'] = $this->getParam('num');#
				$data['firstTime'] = time();#
				$data['productdAttr'] = array(
						'materialType'=>$this->getParam('materialType','t'),
						'luminaireType'=>$this->getParam('luminaireType','t'),
						'tuyereType'=>$this->getParam('tuyereType','t'),
						'productType'=>$this->getParam('productType','t'),
						'size'=>$this->getParam('size','t'),
					  );




             if(empty($resId)){//保存
 			     $insertId=DB::insert("pc_project_product",$data,true) ;
			 }else{//编辑
				 DB::update("pc_project_product",'id = '.$resId,$data);
				 $insertId = $resId;
			 }

//			die(DB::echoExeSql());

		 if($insertId){//保存
				echo $insertId;
				die();
			} else {//失败
				die('0');
			}

		}
	}






	/**
	 * step2删除
	 */
	protected function _del(){

		$resId = $this->getParam('resId','t');//pc_project_product表中的id
		if(isset($resId) && !empty($resId) ){
			if(strpos($resId,',')){
				$where = "id in (".$resId.")";
			}else{
				$where = "id = {$resId}";
			}

			$sql = "delete from pc_project_product where  ".$where;
			$result=DB::execute($sql);
//die(DB::echoExeSql());
			if($result){
				die('1');
			} else {
				die('0');
			}
		}else{ //参数错误
			die('2');
		}
	}




	/**
	 * step2下一步验证
	 */
	protected function  _checkStep(){

		$id = $this->getParam('id','t');

		$sql='SELECT COUNT(*) as SUM from pc_project_product WHERE projectId='.$id;


			$result = DB::select($sql);
//die(DB::echoExeSql());
			if($result[0]['SUM']>0){  //在表中查询到数据
				die($result[0]['SUM']);
			} else {//在表中未查询到数据
				die('0');
			}

		}





	/**
	 * 战略合作申请
	 */


	protected function _strategy()
	{

		if($_SERVER["REQUEST_METHOD"] === "POST"   && $_POST['strategy']==1){
//		 print_r($_POST);exit;
			$data['corpName'] = $this->getParam('corpName','t');#
			$data['countryCode']=$this->getParam('hidden_countrycode','i');
			$data['address'] = $this->getParam('address','t');#
			//图片处理
			if(is_array($_REQUEST['imgup_imgfiles'])&&count($_REQUEST['imgup_imgfiles']>0)){
				$data['bLicense']=join(',',$_REQUEST['imgup_imgfiles']);
			}
			$data['principal'] = $this->getParam('principal','t');#
			$data['principal_mobile'] = $this->getParam('principal_mobile','t');#
			$data['linkman'] = $this->getParam('linkman', 't');#
			$data['tel'] = $this->getParam('tel', 't');#
			$data['mobile'] = $this->getParam('mobile', 't');#
			$data['email'] = $this->getParam('email', 't');#
			$data['status'] = $this->getParam('status', 't');#
			$data['systemId'] = $this->getParam('systemId', 't');#
			$data['operateTime'] = time();#
			$data['firstTime'] = time();#

			$data['status'] = 0;#
			$data['systemId'] = 0;#

			$result=DB::insert("sc_corpinfo",$data);

			if($result ){
				$message="提交成功，我司将安排专人为您提供服务。您以后的任何产品将会得到最迅速的报价及最优化的价格。报价系统登录账号、密码将通过邮件通知给您，请注意查收。";
				$url='http://www.gzcanr.com/cooperate/index.html';
				$this->alertGoto($message,$url);

			}else{
				$this->alertBack("保存失败,请重试！");
			}



		}



		$this->tpl_full_path('/front/cooperate/strategy');
	}



























}
?>
